package com.sunxiansheng.designPattern.factoryandstragy;

import lombok.Getter;

/**
 * Description: 支付策略的类型枚举
 * @Author sun
 * @Create 2024/7/22 10:54
 * @Version 1.0
 */
@Getter
public enum PayChannelEnum {

    ZFB_PAY(0, "支付宝支付"),
    WX_PAY(1, "微信支付"),
    BANK_PAY(2, "银行支付");

    private int code;
    private String desc;

    PayChannelEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * 根据code来获取枚举
     * @param code
     * @return
     */
    public static PayChannelEnum getByCode(int code) {
        for (PayChannelEnum payChannelEnum : PayChannelEnum.values()) {
            if (payChannelEnum.code == code) {
                return payChannelEnum;
            }
        }
        return null;
    }

}